#ifndef IO_UTIL_H
#define IO_UTIL_H

#include <iostream>
#include <cstring>
using namespace std;

inline void Save(ostream& o, const string& s)
{
    size_t size = strlen(s.c_str());
    o.write(reinterpret_cast<const char *>(&size), sizeof(size));
    o.write(s.c_str(), size);
}

inline void Load(istream& i, string& s)
{
    size_t size = 0;
    i.read(reinterpret_cast<char *>(&size), sizeof(size));
    char* buffer = new char[size];
    i.read(buffer, size);
    s = string(buffer,size);
    delete buffer;
}

#endif
